package com.ymatou.iapi.prodstock.testcase;

import com.ymatou.iapi.liveseller.parameter.ActivityProductDto;
import com.ymatou.iapi.liveseller.parameter.CreateLiveActivityBean;
import com.ymatou.iapi.liveseller.parameter.CreateSellerLiveBean;
import com.ymatou.iapi.liveseller.parameter.LiveActivityDto;
import com.ymatou.iapi.prodstock.parameter.AuditProductActivityStockBean;
import com.ymatou.iapi.prodstock.parameter.LockResult;
import com.ymatou.iapi.prodstock.parameter.ProductActivityStockDto;
import com.ymatou.iapi.prodstock.service.AuditProductActivityStockCall;
import com.ymatou.iapi.productmanager.parameter.product.AddSellerProductRequest;
import com.ymatou.mq.admin.parameter.MessageListBean;
import com.ymt.core.tool.Logger;
import com.ymt.database.RedisDriver;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P2;
import com.ymttest.business.service.JobQueryCallService;
import com.ymttest.business.service.LiveRoomCallService;
import com.ymttest.business.service.MqQueryCallService;
import com.ymttest.business.service.ProductManagerCallServiceV2;
import com.ymttest.database.model.LiveRoom;
import com.ymttest.database.model.YmtCatalogsI;
import com.ymttest.database.model.YmtProductActivityStock;
import com.ymttest.database.mongo.jproduct.ActivityProductsWapper;
import com.ymttest.database.mongo.jproduct.ProductsWapperV2;
import com.ymttest.database.sqlwapper.LiveRoomWapper;
import com.ymttest.database.sqlwapper.YmtCatalogsIWapper;
import com.ymttest.database.sqlwapper.YmtProductActivityStockWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.YMTDateUtil;

import cn.ymatou.admin.job.parameter.JobTaskitemListBean;

import org.junit.*;
import org.junit.experimental.categories.Category;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
*报名审核通过初始化活动库存
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_AuditProductActivityStock{
	private static AuditProductActivityStockBean auditproductactivitystockBean;
	private static AuditProductActivityStockCall auditproductactivitystockCall;
	private static int sellerId = Integer.parseInt(EnvSetup.getData("autotest_seller1"));
	private static ArrayList<ProductActivityStockDto> ProductActivityStockDtoList;
	private static ActivityProductsWapper activityProductsWapper = new ActivityProductsWapper();
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("初始化活动库存");
	}

	@Before
	public void caseUp() {
		auditproductactivitystockBean=new AuditProductActivityStockBean();
		auditproductactivitystockCall=new AuditProductActivityStockCall();
		ProductActivityStockDtoList = new ArrayList<ProductActivityStockDto>();
		
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(auditproductactivitystockCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	/**
	 * 2018/7/18
	 * @author zhoulei
	 * @author xintongwei
	 * 发送同步指令 CatalogStockChange不需要验证
	 */
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_AuditProductActivityStock_001() {
		Logger.start(true,"活动商品，活动规格，第一次参加活动");
		try {
			//创建商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			
			//获取商品ID
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			//获取规格ID
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			//创建一个活动  得到活动id
			Integer activityId = ProductManagerCallServiceV2.createIsolationActivityInProcess();
			//报名活动  获得商品在活动中的id
			List<String> aids = ProductManagerCallServiceV2.ApplyActivity(productId, sellerId,catalogs,activityId, 100,"10");
			//活动未开始
			String BeginTime = YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setBeginTime(BeginTime);
			String EndTime = YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setEndTime(EndTime);
			auditproductactivitystockBean.setActivityID(activityId);
			auditproductactivitystockBean.setActivityType(0);
			auditproductactivitystockBean.setProductActivityId(Integer.valueOf(aids.get(0)));
			auditproductactivitystockBean.setUserID(sellerId);
			auditproductactivitystockBean.setProductID(productId);
			auditproductactivitystockBean.setStoreType(-1);
			
			ProductActivityStockDto productActivityStockDto = new ProductActivityStockDto();
			productActivityStockDto.setActivityPrice(new BigDecimal(10));
			productActivityStockDto.setCatalogId(catalogs.get(0));
			productActivityStockDto.setSku(null);
			productActivityStockDto.setStock(200);
			ProductActivityStockDtoList.add(productActivityStockDto);
			auditproductactivitystockBean.setFBXCatalogLockList(ProductActivityStockDtoList);
			auditproductactivitystockCall.setData(auditproductactivitystockBean);
			auditproductactivitystockCall.callService();
			//Logger.debug("活动库存1:"+FormatUtil.beanToGSONString(new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0))));
			String Code = auditproductactivitystockCall.getString("Code");
			Logger.verifyEquals("200",Code,"验证Code");
			auditproductactivitystockCall.getBatchLockResults().forEach(pp->{
				Logger.verifyEquals(catalogs.get(0), pp.getCatalogId(), "验证规格编号");
				Logger.verifyEquals(productId, pp.getProductId(), "验证商品编号");
				Logger.verifyEquals(aids.get(0), pp.getProductInActivityId().toString(), "验证商品在活动中Id");
			});
			/**
			 * catalogNum 初始化规格库存
			 * istocknum 初始化活动库存
			 * icatalogNum 初始化后规格库存
			 * inum 初始化后活动库存
			 */
			//活动库存
			Integer istocknum = new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0)).getIstocknum();
			//商品规格库存
			Integer icatalogNum = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).get(0).getiNum();
			Logger.verifyEquals(catalogNum-istocknum,icatalogNum,"验证商品规格库存与预期期望一致");
			
			//商品活动库存
			Integer inum = new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0)).getIstocknum();
			Logger.verifyEquals(istocknum, inum, "验证商品活动库存与预期期望一致");
			
			//发送同步指令SyncActivityProduct
			MessageListBean MessageListBean = MqQueryCallService.initPMongoCrud(productId);
			List <Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if(joa.size()==0){
				Thread.sleep(5000);
				 joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele->{
				Logger.debug(ele.toString());
			});
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_AuditProductActivityStock_002() {
		Logger.start(true,"普通商品，不同规格，第一次参加活动");
		try {
			/**
			 * 将productActivityStockDto对象中的stock值直接赋值到活动库存
			 */
			//创建商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			
			//获取商品ID
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			//获取规格ID
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			//创建一个活动  得到活动id
			Integer activityId = ProductManagerCallServiceV2.createIsolationActivityInProcess();
			//报名活动  获得商品在活动中的id
			List<String> aids = ProductManagerCallServiceV2.ApplyActivity(productId, sellerId,catalogs,activityId, 100,"10");
			//Logger.debug("活动库存1:"+FormatUtil.beanToGSONString(new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0))));
//			Ymt_ProductActivityStock
			//活动未开始
			String BeginTime = YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setBeginTime(BeginTime);
			String EndTime = YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setEndTime(EndTime);
			auditproductactivitystockBean.setActivityID(activityId);
			auditproductactivitystockBean.setActivityType(0);
			auditproductactivitystockBean.setProductActivityId(Integer.valueOf(aids.get(0)));
			auditproductactivitystockBean.setUserID(sellerId);
			auditproductactivitystockBean.setProductID(productId);
			auditproductactivitystockBean.setStoreType(-1);
			
			ProductActivityStockDto productActivityStockDto1 = new ProductActivityStockDto();
			productActivityStockDto1.setActivityPrice(new BigDecimal(10));
			productActivityStockDto1.setCatalogId(catalogs.get(0));
			productActivityStockDto1.setSku(null);
			productActivityStockDto1.setStock(200);
			productActivityStockDto1.setAction(1);
			ProductActivityStockDto productActivityStockDto2 = new ProductActivityStockDto();
			productActivityStockDto2.setActivityPrice(new BigDecimal(10));
			productActivityStockDto2.setCatalogId(catalogs.get(1));
			productActivityStockDto2.setSku(null);
			productActivityStockDto2.setStock(300);
			ProductActivityStockDtoList.add(productActivityStockDto1);
			ProductActivityStockDtoList.add(productActivityStockDto2);
			auditproductactivitystockBean.setFBXCatalogLockList(ProductActivityStockDtoList);
			auditproductactivitystockCall.setData(auditproductactivitystockBean);
			auditproductactivitystockCall.callService();
			//Logger.debug("活动库存1:"+FormatUtil.beanToGSONString(new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0))));
			String Code = auditproductactivitystockCall.getString("Code");
			Logger.verifyEquals("200",Code,"验证Code");
			LockResult lockResult1 = auditproductactivitystockCall.getBatchLockResults().get(0);
			Logger.verifyEquals(catalogs.get(0), lockResult1.getCatalogId(), "验证规格编号");
			Logger.verifyEquals(productId, lockResult1.getProductId(), "验证商品编号");
			Logger.verifyEquals(aids.get(0), lockResult1.getProductInActivityId().toString(), "验证商品在活动中Id");
			LockResult lockResult2 = auditproductactivitystockCall.getBatchLockResults().get(1);
			Logger.verifyEquals(catalogs.get(1), lockResult2.getCatalogId(), "验证规格编号");
			Logger.verifyEquals(productId, lockResult2.getProductId(), "验证商品编号");
			Logger.verifyEquals(aids.get(0), lockResult2.getProductInActivityId().toString(), "验证商品在活动中Id");
			/**
			 * catalogNum 初始化规格库存
			 * istocknum 初始化活动库存
			 * icatalogNum 初始化后规格库存
			 * inum 初始化后活动库存
			 */
			//活动库存
			Integer istocknum = new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0)).getIstocknum();
			Integer istocknum1 = new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(1)).getIstocknum();
			//商品规格库存
			Integer icatalogNum = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).get(0).getiNum();
			Logger.verifyEquals(catalogNum-productActivityStockDto1.getStock(),icatalogNum,"验证商品规格库存与预期期望一致");
			
			Integer icatalogNum1 = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).get(1).getiNum();
			Logger.verifyEquals(catalogNum-productActivityStockDto2.getStock(),icatalogNum1,"验证商品规格库存与预期期望一致");
			
			//商品活动库存
			Logger.verifyEquals(productActivityStockDto1.getStock(), istocknum, "验证商品活动库存与预期期望一致");
			
			Logger.verifyEquals(productActivityStockDto2.getStock(), istocknum1, "验证商品活动库存与预期期望一致");
			
			//发送同步指令SyncActivityProduct
			MessageListBean MessageListBean = MqQueryCallService.initPMongoCrud(productId);
			List <Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if(joa.size()==0){
				Thread.sleep(5000);
				 joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele->{
				Logger.debug(ele.toString());
			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_AuditProductActivityStock_003() {
		Logger.start(true,"活动商品，活动规格参加活动，活动已经开始");
		try {
			//创建商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			
			//获取商品ID
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			//获取规格ID
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			//创建一个活动  得到活动id
			Integer activityId = ProductManagerCallServiceV2.createIsolationActivityInProcess();
			//报名活动  获得商品在活动中的id
			List<String> aids = ProductManagerCallServiceV2.ApplyActivity(productId, sellerId,catalogs,activityId, 100,"10");
			//审核通过
			ProductManagerCallServiceV2.approveProductInActivity(productId,aids.get(0),true);
			//活动未开始
			String BeginTime = YMTDateUtil.getBeforeOrNextDay(-1, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setBeginTime(BeginTime);
			String EndTime = YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setEndTime(EndTime);
			auditproductactivitystockBean.setActivityID(activityId);
			auditproductactivitystockBean.setActivityType(0);
			auditproductactivitystockBean.setProductActivityId(Integer.valueOf(aids.get(0)));
			auditproductactivitystockBean.setUserID(sellerId);
			auditproductactivitystockBean.setProductID(productId);
			auditproductactivitystockBean.setStoreType(-1);
			
			ProductActivityStockDto productActivityStockDto = new ProductActivityStockDto();
			productActivityStockDto.setActivityPrice(new BigDecimal(10));
			productActivityStockDto.setCatalogId(catalogs.get(0));
			productActivityStockDto.setSku(null);
			Integer stock = 200;
			productActivityStockDto.setStock(stock);
			productActivityStockDto.setAction(0);
			ProductActivityStockDtoList.add(productActivityStockDto);
			auditproductactivitystockBean.setFBXCatalogLockList(ProductActivityStockDtoList);
			auditproductactivitystockCall.setData(auditproductactivitystockBean);
			auditproductactivitystockCall.callService();
			String Code = auditproductactivitystockCall.getString("Code");
			Logger.verifyEquals("200", Code, "验证Code");
			Integer inum = new YmtCatalogsIWapper().selectCatalogsByCatalogId(catalogs.get(0)).getiNum();
			Integer acstock = new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0)).getIstocknum();
			Logger.verifyEquals(stock,acstock,"验证活动库存");
			Logger.verifyEquals(catalogNum - stock,inum,"验证规格库存");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_AuditProductActivityStock_004() {
		Logger.start(true,"活动商品参加活动，活动未开始，action=-1，返规格库存");
		try {
			//创建商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			
			//获取商品ID
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			//获取规格ID
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			//创建一个活动  得到活动id
			Integer activityId = ProductManagerCallServiceV2.createIsolationActivityInProcess();
			//报名活动  获得商品在活动中的id
			List<String> aids = ProductManagerCallServiceV2.ApplyActivity(productId, sellerId,catalogs,activityId, 100,"10");
			//审核通过
			ProductManagerCallServiceV2.approveProductInActivity(productId,aids.get(0),true);
			//活动未开始
			String BeginTime = YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setBeginTime(BeginTime);
			String EndTime = YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setEndTime(EndTime);
			auditproductactivitystockBean.setActivityID(activityId);
			auditproductactivitystockBean.setActivityType(0);
			auditproductactivitystockBean.setProductActivityId(Integer.valueOf(aids.get(0)));
			auditproductactivitystockBean.setUserID(sellerId);
			auditproductactivitystockBean.setProductID(productId);
			auditproductactivitystockBean.setStoreType(-1);
			
			ProductActivityStockDto productActivityStockDto = new ProductActivityStockDto();
			productActivityStockDto.setActivityPrice(new BigDecimal(10));
			productActivityStockDto.setCatalogId(catalogs.get(0));
			productActivityStockDto.setSku(null);
			productActivityStockDto.setStock(200);
			productActivityStockDto.setAction(-1);
			ProductActivityStockDtoList.add(productActivityStockDto);
			auditproductactivitystockBean.setFBXCatalogLockList(ProductActivityStockDtoList);
			auditproductactivitystockCall.setData(auditproductactivitystockBean);
			auditproductactivitystockCall.callService();
			
			String Code = auditproductactivitystockCall.getString("Code");
			Logger.verifyEquals("200",Code,"验证Code");
			auditproductactivitystockCall.getBatchLockResults().forEach(pp->{
				Logger.verifyEquals(catalogs.get(0), pp.getCatalogId(), "验证规格编号");
				Logger.verifyEquals(productId, pp.getProductId(), "验证商品编号");
				Logger.verifyEquals(aids.get(0), pp.getProductInActivityId().toString(), "验证商品在活动中Id");
			});
			/**
			 * catalogNum 初始化规格库存
			 * istocknum 初始化活动库存
			 * icatalogNum 初始化后规格库存
			 * inum 初始化后活动库存
			 */
			//活动库存
			//商品规格库存
			Integer icatalogNum = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).get(0).getiNum();
			Logger.verifyEquals(catalogNum,icatalogNum,"验证商品规格库存与预期期望一致");
			
			//商品活动库存
			Integer inum = new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0)).getIstocknum();
			Logger.verifyEquals(0, inum, "验证商品活动库存与预期期望一致");
			
			//发送同步指令SyncActivityProduct
			MessageListBean MessageListBean = MqQueryCallService.initPMongoCrud(productId);
			List <Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if(joa.size()==0){
				Thread.sleep(5000);
				 joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele->{
				Logger.debug(ele.toString());
			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_AuditProductActivityStock_005() {
		Logger.start(true,"活动商品，活动规格，活动未开始，action=0，参加报名活动");
		try {
			//创建商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			
			//获取商品ID
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			//获取规格ID
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			//创建一个活动  得到活动id
			Integer activityId = ProductManagerCallServiceV2.createIsolationActivityInProcess();
			//报名活动  获得商品在活动中的id
			List<String> aids = ProductManagerCallServiceV2.ApplyActivity(productId, sellerId,catalogs,activityId, 100,"10");
			//审核通过
			ProductManagerCallServiceV2.approveProductInActivity(productId,aids.get(0),true);
			//活动未开始
			String BeginTime = YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setBeginTime(BeginTime);
			String EndTime = YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setEndTime(EndTime);
			auditproductactivitystockBean.setActivityID(activityId);
			auditproductactivitystockBean.setActivityType(0);
			auditproductactivitystockBean.setProductActivityId(Integer.valueOf(aids.get(0)));
			auditproductactivitystockBean.setUserID(sellerId);
			auditproductactivitystockBean.setProductID(productId);
			auditproductactivitystockBean.setStoreType(-1);
			
			ProductActivityStockDto productActivityStockDto = new ProductActivityStockDto();
			productActivityStockDto.setActivityPrice(new BigDecimal(10));
			productActivityStockDto.setCatalogId(catalogs.get(0));
			productActivityStockDto.setSku(null);
			//初始值<>和=传入值,将传入值作为活动库存数量值
			productActivityStockDto.setStock(50);
			//productActivityStockDto.setStock(100);
			productActivityStockDto.setAction(0);
			ProductActivityStockDtoList.add(productActivityStockDto);
			auditproductactivitystockBean.setFBXCatalogLockList(ProductActivityStockDtoList);
			auditproductactivitystockCall.setData(auditproductactivitystockBean);
			auditproductactivitystockCall.callService();
			
			String Code = auditproductactivitystockCall.getString("Code");
			Logger.verifyEquals("200",Code,"验证Code");
			auditproductactivitystockCall.getBatchLockResults().forEach(pp->{
				Logger.verifyEquals(catalogs.get(0), pp.getCatalogId(), "验证规格编号");
				Logger.verifyEquals(productId, pp.getProductId(), "验证商品编号");
				Logger.verifyEquals(aids.get(0), pp.getProductInActivityId().toString(), "验证商品在活动中Id");
			});
			/**
			 * catalogNum 初始化规格库存
			 * istocknum 初始化活动库存
			 * icatalogNum 初始化后规格库存
			 * inum 初始化后活动库存
			 */
			//活动库存
			//商品规格库存
			Integer icatalogNum = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).get(0).getiNum();
			Logger.verifyEquals(catalogNum-productActivityStockDto.getStock(),icatalogNum,"验证商品规格库存与预期期望一致");
			Logger.debug(catalogNum-productActivityStockDto.getStock());
			//商品活动库存
			Integer inum = new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0)).getIstocknum();
			Logger.verifyEquals(productActivityStockDto.getStock(), inum, "验证商品活动库存与预期期望一致");
			Logger.debug(productActivityStockDto.getStock());
			//发送同步指令SyncActivityProduct
			MessageListBean MessageListBean = MqQueryCallService.initPMongoCrud(productId);
			List <Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if(joa.size()==0){
				Thread.sleep(5000);
				 joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele->{
				Logger.debug(ele.toString());
			});
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_AuditProductActivityStock_006() {
		Logger.start(true,"活动商品，多个规格参与活动，有的规格action=-1，有的规格action=0");
		try {
			/**
			 * 返回报文中，-1的规格不返回，只返回0的
			 */
			//创建商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			
			//获取商品ID
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			//获取规格ID
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			//创建一个活动  得到活动id
			Integer activityId = ProductManagerCallServiceV2.createIsolationActivityInProcess();
			//报名活动  获得商品在活动中的id
			List<String> aids = ProductManagerCallServiceV2.ApplyActivity(productId, sellerId,catalogs,activityId, 100,"10");
			//审核通过
			ProductManagerCallServiceV2.approveProductInActivity(productId,aids.get(0),true);
			//活动未开始
			String BeginTime = YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setBeginTime(BeginTime);
			String EndTime = YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setEndTime(EndTime);
			auditproductactivitystockBean.setActivityID(activityId);
			auditproductactivitystockBean.setActivityType(0);
			auditproductactivitystockBean.setProductActivityId(Integer.valueOf(aids.get(0)));
			auditproductactivitystockBean.setUserID(sellerId);
			auditproductactivitystockBean.setProductID(productId);
			auditproductactivitystockBean.setStoreType(-1);
			
			ProductActivityStockDto productActivityStockDto1 = new ProductActivityStockDto();
			productActivityStockDto1.setActivityPrice(new BigDecimal(10));
			productActivityStockDto1.setCatalogId(catalogs.get(0));
			productActivityStockDto1.setSku(null);
			productActivityStockDto1.setStock(200);
			productActivityStockDto1.setAction(0);
			ProductActivityStockDto productActivityStockDto2 = new ProductActivityStockDto();
			productActivityStockDto2.setActivityPrice(new BigDecimal(10));
			productActivityStockDto2.setCatalogId(catalogs.get(1));
			productActivityStockDto2.setSku(null);
			productActivityStockDto2.setStock(300);
			productActivityStockDto2.setAction(-1);
			ProductActivityStockDtoList.add(productActivityStockDto1);
			ProductActivityStockDtoList.add(productActivityStockDto2);
			auditproductactivitystockBean.setFBXCatalogLockList(ProductActivityStockDtoList);
			auditproductactivitystockCall.setData(auditproductactivitystockBean);
			auditproductactivitystockCall.callService();
			String Code = auditproductactivitystockCall.getString("Code");
			Logger.verifyEquals("200",Code,"验证Code");
			LockResult lockResult1 = auditproductactivitystockCall.getBatchLockResults().get(0);
			Logger.verifyEquals(catalogs.get(0), lockResult1.getCatalogId(), "验证规格编号");
			Logger.verifyEquals(productId, lockResult1.getProductId(), "验证商品编号");
			Logger.verifyEquals(aids.get(0), lockResult1.getProductInActivityId().toString(), "验证商品在活动中Id");
			/**
			 * catalogNum 初始化规格库存
			 * istocknum 初始化活动库存
			 * icatalogNum 初始化后规格库存
			 * inum 初始化后活动库存
			 */
			//商品规格库存
			Integer icatalogNum = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).get(0).getiNum();
			Logger.verifyEquals(catalogNum-productActivityStockDto1.getStock(),icatalogNum,"验证商品规格库存1与预期期望一致");
			
			Integer icatalogNum1 = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).get(1).getiNum();
			Logger.verifyEquals(catalogNum,icatalogNum1,"验证商品规格库存2与预期期望一致");
			
			//商品活动库存
			Integer inum = new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0)).getIstocknum();
			Logger.verifyEquals(productActivityStockDto1.getStock(), inum, "验证商品活动库存1与预期期望一致");
			
			Integer inum1 = new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(1)).getIstocknum();
			Logger.verifyEquals(0, inum1, "验证商品活动库存2与预期期望一致");
			
			//发送同步指令SyncActivityProduct
			MessageListBean MessageListBean = MqQueryCallService.initPMongoCrud(productId);
			List <Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if(joa.size()==0){
				Thread.sleep(5000);
				 joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele->{
				Logger.debug(ele.toString());
			});	
						
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	/*@Test
	@Category({P3.class})
	@TestCase
	public void Tc_AuditProductActivityStock_007() {
		Logger.start(true,"同一种商品，不同规格批量参与报名，某个规格没有参加报名,action=0");
		try {
			//创建商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			addpro.getProduct().getCatalogList().remove(0);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			
			//获取商品ID
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			//获取规格ID
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			//String catalog0 = catalogs.remove(1);
			//创建一个活动  得到活动id
			Integer activityId = ProductManagerCallServiceV2.createIsolationActivityInProcess();
			//报名活动  获得商品在活动中的id
			List<String> aids = ProductManagerCallServiceV2.ApplyActivity(productId, sellerId,catalogs,activityId, 100,"10");
			//审核通过
			ProductManagerCallServiceV2.approveProductInActivity(productId,aids.get(0),true);
			//活动未开始
			String BeginTime = YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setBeginTime(BeginTime);
			String EndTime = YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setEndTime(EndTime);
			auditproductactivitystockBean.setActivityID(activityId);
			auditproductactivitystockBean.setActivityType(0);
			auditproductactivitystockBean.setProductActivityId(Integer.valueOf(aids.get(0)));
			auditproductactivitystockBean.setUserID(sellerId);
			auditproductactivitystockBean.setProductID(productId);
			auditproductactivitystockBean.setStoreType(-1);
			
			ProductActivityStockDto productActivityStockDto1 = new ProductActivityStockDto();
			productActivityStockDto1.setActivityPrice(new BigDecimal(10));
			productActivityStockDto1.setCatalogId(catalogs.get(0));
			productActivityStockDto1.setSku(null);
			productActivityStockDto1.setStock(200);
			productActivityStockDto1.setAction(0);
			ProductActivityStockDto productActivityStockDto2 = new ProductActivityStockDto();
			productActivityStockDto2.setActivityPrice(new BigDecimal(10));
			productActivityStockDto2.setCatalogId(catalog0);
			productActivityStockDto2.setSku(null);
			productActivityStockDto2.setStock(300);
			productActivityStockDto2.setAction(0);
			ProductActivityStockDtoList.add(productActivityStockDto1);
			ProductActivityStockDtoList.add(productActivityStockDto2);
			auditproductactivitystockBean.setFBXCatalogLockList(ProductActivityStockDtoList);
			auditproductactivitystockCall.setData(auditproductactivitystockBean);
			auditproductactivitystockCall.callService();
			//Logger.debug("活动库存1:"+FormatUtil.beanToGSONString(new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0))));
			String Code = auditproductactivitystockCall.getString("Code");
			Logger.verifyEquals("200",Code,"验证Code");
			LockResult lockResult1 = auditproductactivitystockCall.getBatchLockResults().get(0);
			Logger.verifyEquals(catalogs.get(0), lockResult1.getCatalogId(), "验证规格编号");
			Logger.verifyEquals(productId, lockResult1.getProductId(), "验证商品编号");
			Logger.verifyEquals(aids.get(0), lockResult1.getProductInActivityId().toString(), "验证商品在活动中Id");
			LockResult lockResult2 = auditproductactivitystockCall.getBatchLockResults().get(1);
			Logger.verifyEquals(catalog0, lockResult2.getCatalogId(), "验证规格编号");
			Logger.verifyEquals(productId, lockResult2.getProductId(), "验证商品编号");
			Logger.verifyEquals(aids.get(0), lockResult2.getProductInActivityId().toString(), "验证商品在活动中Id");
			*//**
			 * catalogNum 初始化规格库存
			 * istocknum 初始化活动库存
			 * icatalogNum 初始化后规格库存
			 * inum 初始化后活动库存
			 *//*
			//商品规格库存
			Integer icatalogNum = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).get(0).getiNum();
			Logger.verifyEquals(catalogNum-productActivityStockDto2.getStock(),icatalogNum,"验证商品规格库存与预期期望一致");
			
			Integer icatalogNum1 = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).get(1).getiNum();
			Logger.verifyEquals(catalogNum-productActivityStockDto1.getStock(),icatalogNum1,"验证商品规格库存与预期期望一致");
			
			//商品活动库存
			Integer inum = new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0)).getIstocknum();
			Logger.verifyEquals(productActivityStockDto1.getStock(), inum, "验证商品活动库存与预期期望一致");
			
			Integer inum1 = new YmtProductActivityStockWapper().selectByCatalogId(catalog0).getIstocknum();
			Logger.verifyEquals(productActivityStockDto2.getStock(), inum1, "验证商品活动库存与预期期望一致");
			
			//发送同步指令SyncActivityProduct
			MessageListBean MessageListBean = MqQueryCallService.initPMongoCrud(productId);
			List <Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if(joa.size()==0){
				Thread.sleep(5000);
				 joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele->{
				Logger.debug(ele.toString());
			});		
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_AuditProductActivityStock_008() {
		Logger.start(true,"同一种商品，不同规格批量参与报名，某个规格没有参加报名,action=-1");
		try {
			*//**
			 * 
			 *//*
			//创建商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			
			//获取商品ID
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			//获取规格ID
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			String catalog0 = catalogs.remove(0);
			//创建一个活动  得到活动id
			Integer activityId = ProductManagerCallServiceV2.createIsolationActivityInProcess();
			//报名活动  获得商品在活动中的id
			List<String> aids = ProductManagerCallServiceV2.ApplyActivity(productId, sellerId,catalogs,activityId, 100,"10");
			//审核通过
			ProductManagerCallServiceV2.approveProductInActivity(productId,aids.get(0),true);
			//活动未开始
			String BeginTime = YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setBeginTime(BeginTime);
			String EndTime = YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setEndTime(EndTime);
			auditproductactivitystockBean.setActivityID(activityId);
			auditproductactivitystockBean.setActivityType(0);
			auditproductactivitystockBean.setProductActivityId(Integer.valueOf(aids.get(0)));
			auditproductactivitystockBean.setUserID(sellerId);
			auditproductactivitystockBean.setProductID(productId);
			auditproductactivitystockBean.setStoreType(-1);
			
			ProductActivityStockDto productActivityStockDto1 = new ProductActivityStockDto();
			productActivityStockDto1.setActivityPrice(new BigDecimal(10));
			productActivityStockDto1.setCatalogId(catalogs.get(0));
			productActivityStockDto1.setSku(null);
			productActivityStockDto1.setStock(200);
			productActivityStockDto1.setAction(-1);
			ProductActivityStockDto productActivityStockDto2 = new ProductActivityStockDto();
			productActivityStockDto2.setActivityPrice(new BigDecimal(10));
			productActivityStockDto2.setCatalogId(catalog0);
			productActivityStockDto2.setSku(null);
			productActivityStockDto2.setStock(300);
			productActivityStockDto2.setAction(-1);
			ProductActivityStockDtoList.add(productActivityStockDto1);
			ProductActivityStockDtoList.add(productActivityStockDto2);
			auditproductactivitystockBean.setFBXCatalogLockList(ProductActivityStockDtoList);
			auditproductactivitystockCall.setData(auditproductactivitystockBean);
			auditproductactivitystockCall.callService();
			//Logger.debug("活动库存1:"+FormatUtil.beanToGSONString(new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0))));
			String Code = auditproductactivitystockCall.getString("Code");
			Logger.verifyEquals("200",Code,"验证Code");
			*//**
			 * catalogNum 初始化规格库存
			 * istocknum 初始化活动库存
			 * icatalogNum 初始化后规格库存
			 * inum 初始化后活动库存
			 *//*
			//商品规格库存
			Integer icatalogNum = new YmtCatalogsIWapper().selectCatalogsByCatalogId(catalog0).getiNum();
			Logger.verifyEquals(catalogNum,icatalogNum,"验证商品规格库存与预期期望一致");
			
			Integer icatalogNum1 = new YmtCatalogsIWapper().selectCatalogsByCatalogId(catalogs.get(0)).getiNum();
			Logger.verifyEquals(catalogNum,icatalogNum1,"验证商品规格库存与预期期望一致");
			
			//商品活动库存
			Integer inum = new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0)).getIstocknum();
			Logger.verifyEquals(0, inum, "验证商品活动库存与预期期望一致");
			
			
			//发送同步指令SyncActivityProduct
			MessageListBean MessageListBean = MqQueryCallService.initPMongoCrud(productId);
			List <Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if(joa.size()==0){
				Thread.sleep(5000);
				 joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele->{
				Logger.debug(ele.toString());
			});		
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_AuditProductActivityStock_009() {
		Logger.start(true,"活动商品，不同规格，某个规格未参加活动，不传action");
		try {
			*//**
			 * 默认action=0进行操作
			 *//*
			//创建商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			
			//获取商品ID
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			//获取规格ID
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			String catalog0 = catalogs.remove(0);
			//创建一个活动  得到活动id
			Integer activityId = ProductManagerCallServiceV2.createIsolationActivityInProcess();
			//报名活动  获得商品在活动中的id
			List<String> aids = ProductManagerCallServiceV2.ApplyActivity(productId, sellerId,catalogs,activityId, 100,"10");
			//审核通过
			ProductManagerCallServiceV2.approveProductInActivity(productId,aids.get(0),true);
			//活动未开始
			String BeginTime = YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setBeginTime(BeginTime);
			String EndTime = YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setEndTime(EndTime);
			auditproductactivitystockBean.setActivityID(activityId);
			auditproductactivitystockBean.setActivityType(0);
			auditproductactivitystockBean.setProductActivityId(Integer.valueOf(aids.get(0)));
			auditproductactivitystockBean.setUserID(sellerId);
			auditproductactivitystockBean.setProductID(productId);
			auditproductactivitystockBean.setStoreType(-1);
			
			ProductActivityStockDto productActivityStockDto1 = new ProductActivityStockDto();
			productActivityStockDto1.setActivityPrice(new BigDecimal(10));
			productActivityStockDto1.setCatalogId(catalogs.get(0));
			productActivityStockDto1.setSku(null);
			productActivityStockDto1.setStock(200);
			ProductActivityStockDto productActivityStockDto2 = new ProductActivityStockDto();
			productActivityStockDto2.setActivityPrice(new BigDecimal(10));
			productActivityStockDto2.setCatalogId(catalog0);
			productActivityStockDto2.setSku(null);
			productActivityStockDto2.setStock(300);
			ProductActivityStockDtoList.add(productActivityStockDto1);
			ProductActivityStockDtoList.add(productActivityStockDto2);
			auditproductactivitystockBean.setFBXCatalogLockList(ProductActivityStockDtoList);
			auditproductactivitystockCall.setData(auditproductactivitystockBean);
			auditproductactivitystockCall.callService();
			//Logger.debug("活动库存1:"+FormatUtil.beanToGSONString(new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0))));
			String Code = auditproductactivitystockCall.getString("Code");
			Logger.verifyEquals("200",Code,"验证Code");
			LockResult lockResult1 = auditproductactivitystockCall.getBatchLockResults().get(0);
			Logger.verifyEquals(catalogs.get(0), lockResult1.getCatalogId(), "验证规格编号");
			Logger.verifyEquals(productId, lockResult1.getProductId(), "验证商品编号");
			Logger.verifyEquals(aids.get(0), lockResult1.getProductInActivityId().toString(), "验证商品在活动中Id");
			LockResult lockResult2 = auditproductactivitystockCall.getBatchLockResults().get(1);
			Logger.verifyEquals(catalog0, lockResult2.getCatalogId(), "验证规格编号");
			Logger.verifyEquals(productId, lockResult2.getProductId(), "验证商品编号");
			Logger.verifyEquals(aids.get(0), lockResult2.getProductInActivityId().toString(), "验证商品在活动中Id");
			*//**
			 * catalogNum 初始化规格库存
			 * istocknum 初始化活动库存
			 * icatalogNum 初始化后规格库存
			 * inum 初始化后活动库存
			 *//*
			//商品规格库存
			Integer icatalogNum = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).get(0).getiNum();
			Logger.verifyEquals(catalogNum-productActivityStockDto2.getStock(),icatalogNum,"验证商品规格库存与预期期望一致");
			
			Integer icatalogNum1 = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).get(1).getiNum();
			Logger.verifyEquals(catalogNum-productActivityStockDto1.getStock(),icatalogNum1,"验证商品规格库存与预期期望一致");
			
			//商品活动库存
			Integer inum = new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0)).getIstocknum();
			Logger.verifyEquals(productActivityStockDto1.getStock(), inum, "验证商品活动库存与预期期望一致");
			
			Integer inum1 = new YmtProductActivityStockWapper().selectByCatalogId(catalog0).getIstocknum();
			Logger.verifyEquals(productActivityStockDto2.getStock(), inum1, "验证商品活动库存与预期期望一致");
			
			//发送同步指令SyncActivityProduct
			MessageListBean MessageListBean = MqQueryCallService.initPMongoCrud(productId);
			List <Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if(joa.size()==0){
				Thread.sleep(5000);
				 joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele->{
				Logger.debug(ele.toString());
			});		
		} catch (Exception e) {
			Logger.fail(e);
		}
	}*/
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_AuditProductActivityStock_010() {
		Logger.start(true,"活动商品，不同规格，参加活动，不传库存参数，或参数为负数");
		try {
			/**
			 * 全部操作失败
			 */
			//创建商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			
			//获取商品ID
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			//获取规格ID
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			//创建一个活动  得到活动id
			Integer activityId = ProductManagerCallServiceV2.createIsolationActivityInProcess();
			//报名活动  获得商品在活动中的id
			List<String> aids = ProductManagerCallServiceV2.ApplyActivity(productId, sellerId,catalogs,activityId, 100,"10");
			//审核通过
			ProductManagerCallServiceV2.approveProductInActivity(productId,aids.get(0),true);
			//活动未开始
			String BeginTime = YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setBeginTime(BeginTime);
			String EndTime = YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setEndTime(EndTime);
			auditproductactivitystockBean.setActivityID(activityId);
			auditproductactivitystockBean.setActivityType(0);
			auditproductactivitystockBean.setProductActivityId(Integer.valueOf(aids.get(0)));
			auditproductactivitystockBean.setUserID(sellerId);
			auditproductactivitystockBean.setProductID(productId);
			auditproductactivitystockBean.setStoreType(-1);
			
			ProductActivityStockDto productActivityStockDto1 = new ProductActivityStockDto();
			productActivityStockDto1.setActivityPrice(new BigDecimal(10));
			productActivityStockDto1.setCatalogId(catalogs.get(0));
			productActivityStockDto1.setSku(null);
			productActivityStockDto1.setStock(200);
			ProductActivityStockDto productActivityStockDto2 = new ProductActivityStockDto();
			productActivityStockDto2.setActivityPrice(new BigDecimal(10));
			productActivityStockDto2.setCatalogId(catalogs.get(1));
			productActivityStockDto2.setSku(null);
			productActivityStockDto2.setStock(-1);
			ProductActivityStockDtoList.add(productActivityStockDto1);
			ProductActivityStockDtoList.add(productActivityStockDto2);
			auditproductactivitystockBean.setFBXCatalogLockList(ProductActivityStockDtoList);
			auditproductactivitystockCall.setData(auditproductactivitystockBean);
			auditproductactivitystockCall.callService();
			//Logger.debug("活动库存1:"+FormatUtil.beanToGSONString(new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0))));
			String Code = auditproductactivitystockCall.getString("Code");
			Logger.verifyEquals("201",Code,"验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_AuditProductActivityStock_011() {
		Logger.start(true,"同一活动商品，不同活动规格，秒杀活动，action = -1");
		try {
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Logger.comment("创建直播");
			// 5分钟后开始200分钟后结束
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			//半小时之内会锁定不能修改
			Date starttime = new Date(now.getTime() + 60 * 60 * 1000);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));
			
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(clive);
			Logger.comment("加入商品");
			LiveRoomCallService.AddProductsToLive(createlive.getId(), sellerId, productId);
			Logger.comment("查询商品规格");
			YmtCatalogsIWapper CIWapper = new YmtCatalogsIWapper();
			List<String> cids = CIWapper.selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			Logger.comment("创建秒杀活动");
			
			CreateLiveActivityBean createliveactivityBean = new CreateLiveActivityBean();
			LiveActivityDto LiveActivity=new LiveActivityDto();
			List<ActivityProductDto> ActivityProducts=new ArrayList<>();
			ActivityProductDto activityProductDto1 = new ActivityProductDto();
			activityProductDto1.setProductId(productId);
			activityProductDto1.setActivityPrice(7d);
			activityProductDto1.setActivityStock(6);
			activityProductDto1.setCatalogId(cids.get(0));
			ActivityProductDto activityProductDto2 = new ActivityProductDto();
			activityProductDto2.setProductId(productId);
			activityProductDto2.setActivityPrice(7d);
			activityProductDto2.setActivityStock(6);
			activityProductDto2.setCatalogId(cids.get(1));
			ActivityProducts.add(activityProductDto1);
			ActivityProducts.add(activityProductDto2);
			
			LiveActivity.setActivityProducts(ActivityProducts);
			LiveActivity.setStartTime(String.valueOf(starttime.getTime()));
			LiveActivity.setEndTime(String.valueOf(starttime.getTime()+1*60*1000));
			LiveActivity.setLiveId(createlive.getId());
			LiveActivity.setSellerId(sellerId);
			createliveactivityBean.setLiveActivity(LiveActivity);
			
			createliveactivityBean.getLiveActivity().setActivityProducts(ActivityProducts);
			LiveRoomCallService.CreateLiveActivity(createliveactivityBean);
			LiveRoomWapper LiveRoomWapper = new LiveRoomWapper();
			Integer liveActivityId = LiveRoomWapper.selectLiveactivityByLiveId(createliveactivityBean.getLiveActivity().getLiveId()).get(0).getLiveActivityId();
			Integer LiveActivityProductId = LiveRoomWapper.selectLiveactivityproduct(liveActivityId, LiveActivity.getActivityProducts().get(0).getProductId()).get(0).getLiveActivityProductId();
			
			//活动未开始
			String BeginTime = YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setBeginTime(BeginTime);
			String EndTime = YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setEndTime(EndTime);
			auditproductactivitystockBean.setActivityID(liveActivityId);
			auditproductactivitystockBean.setActivityType(1);
			auditproductactivitystockBean.setProductActivityId(LiveActivityProductId);
			auditproductactivitystockBean.setUserID(sellerId);
			auditproductactivitystockBean.setProductID(productId);
			auditproductactivitystockBean.setStoreType(-1);
            auditproductactivitystockBean.setSourceId(createlive.getId());
			auditproductactivitystockBean.setSourceId(createlive.getId());
			
			ProductActivityStockDto productActivityStockDto1 = new ProductActivityStockDto();
			productActivityStockDto1.setActivityPrice(new BigDecimal(2));
			productActivityStockDto1.setCatalogId(cids.get(0));
			productActivityStockDto1.setSku(null);
			productActivityStockDto1.setStock(200);
			productActivityStockDto1.setAction(-1);

			ProductActivityStockDto productActivityStockDto2 = new ProductActivityStockDto();
			productActivityStockDto2.setActivityPrice(new BigDecimal(2));
			productActivityStockDto2.setCatalogId(cids.get(1));
			productActivityStockDto2.setSku(null);
			productActivityStockDto2.setStock(300);
			productActivityStockDto2.setAction(-1);
			ProductActivityStockDtoList.add(productActivityStockDto1);
			ProductActivityStockDtoList.add(productActivityStockDto2);
			auditproductactivitystockBean.setFBXCatalogLockList(ProductActivityStockDtoList);
			auditproductactivitystockCall.setData(auditproductactivitystockBean);
			auditproductactivitystockCall.callService();
			//Logger.debug("活动库存1:"+FormatUtil.beanToGSONString(new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0))));
			String Code = auditproductactivitystockCall.getString("Code");
			Logger.verifyEquals("200",Code,"验证Code");
			
			//商品规格库存
			Integer icatalogNum1 = new YmtCatalogsIWapper().selectCatalogsByCatalogId(cids.get(0)).getiNum();
			Integer icatalogNum2 = new YmtCatalogsIWapper().selectCatalogsByCatalogId(cids.get(1)).getiNum();
			Logger.verifyEquals(catalogNum,icatalogNum1,"验证商品规格库存与预期期望一致");
			Logger.verifyEquals(catalogNum,icatalogNum2,"验证商品规格库存与预期期望一致");
			
			//发送同步指令SyncActivityProduct
			MessageListBean MessageListBean = MqQueryCallService.initPMongoCrud(productId);
			List <Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if(joa.size()==0){
				Thread.sleep(5000);
				 joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele->{
				Logger.debug(ele.toString());
			});
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_AuditProductActivityStock_012() {
		Logger.start(true,"同一活动商品，不同活动规格，秒杀活动，action=0");
		try {
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Logger.comment("创建直播");
			// 5分钟后开始200分钟后结束
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			//半小时之内会锁定不能修改
			Date starttime = new Date(now.getTime() + 60 * 60 * 1000);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));
			
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(clive);
			Logger.comment("加入商品");
			LiveRoomCallService.AddProductsToLive(createlive.getId(), sellerId, productId);
			Logger.comment("查询商品规格");
			YmtCatalogsIWapper CIWapper = new YmtCatalogsIWapper();
			List<String> cids = CIWapper.selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			Logger.comment("创建秒杀活动");
			
			CreateLiveActivityBean createliveactivityBean = new CreateLiveActivityBean();
			LiveActivityDto LiveActivity=new LiveActivityDto();
			List<ActivityProductDto> ActivityProducts=new ArrayList<>();
			ActivityProductDto activityProductDto1 = new ActivityProductDto();
			activityProductDto1.setProductId(productId);
			activityProductDto1.setActivityPrice(7d);
			activityProductDto1.setActivityStock(6);
			activityProductDto1.setCatalogId(cids.get(0));
			ActivityProductDto activityProductDto2 = new ActivityProductDto();
			activityProductDto2.setProductId(productId);
			activityProductDto2.setActivityPrice(7d);
			activityProductDto2.setActivityStock(6);
			activityProductDto2.setCatalogId(cids.get(1));
			ActivityProducts.add(activityProductDto1);
			ActivityProducts.add(activityProductDto2);
			
			LiveActivity.setActivityProducts(ActivityProducts);
			LiveActivity.setStartTime(String.valueOf(starttime.getTime()));
			LiveActivity.setEndTime(String.valueOf(starttime.getTime()+1*60*1000));
			LiveActivity.setLiveId(createlive.getId());
			LiveActivity.setSellerId(sellerId);
			createliveactivityBean.setLiveActivity(LiveActivity);
			
			createliveactivityBean.getLiveActivity().setActivityProducts(ActivityProducts);
			LiveRoomCallService.CreateLiveActivity(createliveactivityBean);
			LiveRoomWapper LiveRoomWapper = new LiveRoomWapper();
			Integer liveActivityId = LiveRoomWapper.selectLiveactivityByLiveId(createliveactivityBean.getLiveActivity().getLiveId()).get(0).getLiveActivityId();
			Integer LiveActivityProductId = LiveRoomWapper.selectLiveactivityproduct(liveActivityId, LiveActivity.getActivityProducts().get(0).getProductId()).get(0).getLiveActivityProductId();
			
			//活动未开始
			String BeginTime = YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setBeginTime(BeginTime);
			String EndTime = YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setEndTime(EndTime);
			auditproductactivitystockBean.setActivityID(liveActivityId);
			auditproductactivitystockBean.setActivityType(1);
			auditproductactivitystockBean.setProductActivityId(LiveActivityProductId);
			auditproductactivitystockBean.setUserID(sellerId);
			auditproductactivitystockBean.setProductID(productId);
			auditproductactivitystockBean.setStoreType(-1);
			auditproductactivitystockBean.setSourceId(createlive.getId());
			
			ProductActivityStockDto productActivityStockDto1 = new ProductActivityStockDto();
			productActivityStockDto1.setActivityPrice(new BigDecimal(2));
			productActivityStockDto1.setCatalogId(cids.get(0));
			productActivityStockDto1.setSku(null);
			productActivityStockDto1.setStock(300);
			productActivityStockDto1.setAction(0);

			ProductActivityStockDto productActivityStockDto2 = new ProductActivityStockDto();
			productActivityStockDto2.setActivityPrice(new BigDecimal(2));
			productActivityStockDto2.setCatalogId(cids.get(1));
			productActivityStockDto2.setSku(null);
			productActivityStockDto2.setStock(200);
			productActivityStockDto2.setAction(0);
			ProductActivityStockDtoList.add(productActivityStockDto1);
			ProductActivityStockDtoList.add(productActivityStockDto2);
			auditproductactivitystockBean.setFBXCatalogLockList(ProductActivityStockDtoList);
			auditproductactivitystockCall.setData(auditproductactivitystockBean);
			auditproductactivitystockCall.callService();
			//Logger.debug("活动库存1:"+FormatUtil.beanToGSONString(new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0))));
			String Code = auditproductactivitystockCall.getString("Code");
			Logger.verifyEquals("200",Code,"验证Code");
			LockResult lockResult1 = auditproductactivitystockCall.getBatchLockResults().get(0);
			Logger.verifyEquals(cids.get(0), lockResult1.getCatalogId(), "验证规格编号");
			Logger.verifyEquals(productId, lockResult1.getProductId(), "验证商品编号");
			Logger.verifyEquals(LiveActivityProductId, lockResult1.getProductInActivityId(), "验证商品在活动中Id");
			
			LockResult lockResult2 = auditproductactivitystockCall.getBatchLockResults().get(1);
			Logger.verifyEquals(cids.get(1), lockResult2.getCatalogId(), "验证规格编号");
			Logger.verifyEquals(productId, lockResult2.getProductId(), "验证商品编号");
			Logger.verifyEquals(LiveActivityProductId, lockResult2.getProductInActivityId(), "验证商品在活动中Id");
			
			//商品规格库存
			Integer icatalogNum1 = new YmtCatalogsIWapper().selectCatalogsByCatalogId(cids.get(0)).getiNum();
			Integer icatalogNum2 = new YmtCatalogsIWapper().selectCatalogsByCatalogId(cids.get(1)).getiNum();
			Logger.verifyEquals(catalogNum-productActivityStockDto1.getStock(),icatalogNum1,"验证商品规格库存与预期期望一致");
			Logger.verifyEquals(catalogNum-productActivityStockDto2.getStock(),icatalogNum2,"验证商品规格库存与预期期望一致");
			
			//商品活动库存
			Integer inum1 = new YmtProductActivityStockWapper().selectByCatalogId(cids.get(0)).getIstocknum();
			Integer inum2 = new YmtProductActivityStockWapper().selectByCatalogId(cids.get(1)).getIstocknum();
			Logger.verifyEquals(productActivityStockDto1.getStock(), inum1, "验证商品活动库存与预期期望一致");
			Logger.verifyEquals(productActivityStockDto2.getStock(), inum2, "验证商品活动库存与预期期望一致");
			
			//发送同步指令SyncActivityProduct
			MessageListBean MessageListBean = MqQueryCallService.initPMongoCrud(productId);
			List <Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if(joa.size()==0){
				Thread.sleep(5000);
				 joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele->{
				Logger.debug(ele.toString());
			});
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_AuditProductActivityStock_013() {
		Logger.start(true,"同一活动商品，不同活动规格，秒杀活动，规格库存不足，action=0");
		try {
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 100;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Logger.comment("创建直播");
			// 5分钟后开始200分钟后结束
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			//半小时之内会锁定不能修改
			Date starttime = new Date(now.getTime() + 60 * 60 * 1000);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));
			
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(clive);
			Logger.comment("加入商品");
			LiveRoomCallService.AddProductsToLive(createlive.getId(), sellerId, productId);
			Logger.comment("查询商品规格");
			YmtCatalogsIWapper CIWapper = new YmtCatalogsIWapper();
			List<String> cids = CIWapper.selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			Logger.comment("创建秒杀活动");
			
			CreateLiveActivityBean createliveactivityBean = new CreateLiveActivityBean();
			LiveActivityDto LiveActivity=new LiveActivityDto();
			List<ActivityProductDto> ActivityProducts=new ArrayList<>();
			ActivityProductDto activityProductDto1 = new ActivityProductDto();
			activityProductDto1.setProductId(productId);
			activityProductDto1.setActivityPrice(7d);
			activityProductDto1.setActivityStock(100);
			activityProductDto1.setCatalogId(cids.get(0));
			ActivityProductDto activityProductDto2 = new ActivityProductDto();
			activityProductDto2.setProductId(productId);
			activityProductDto2.setActivityPrice(7d);
			activityProductDto2.setActivityStock(100);
			activityProductDto2.setCatalogId(cids.get(1));
			ActivityProducts.add(activityProductDto1);
			ActivityProducts.add(activityProductDto2);
			
			LiveActivity.setActivityProducts(ActivityProducts);
			LiveActivity.setStartTime(String.valueOf(starttime.getTime()));
			LiveActivity.setEndTime(String.valueOf(starttime.getTime()+1*60*1000));
			LiveActivity.setLiveId(createlive.getId());
			LiveActivity.setSellerId(sellerId);
			createliveactivityBean.setLiveActivity(LiveActivity);
			
			createliveactivityBean.getLiveActivity().setActivityProducts(ActivityProducts);
			LiveRoomCallService.CreateLiveActivity(createliveactivityBean);
			LiveRoomWapper LiveRoomWapper = new LiveRoomWapper();
			Integer liveActivityId = LiveRoomWapper.selectLiveactivityByLiveId(createliveactivityBean.getLiveActivity().getLiveId()).get(0).getLiveActivityId();
			Integer LiveActivityProductId = LiveRoomWapper.selectLiveactivityproduct(liveActivityId, LiveActivity.getActivityProducts().get(0).getProductId()).get(0).getLiveActivityProductId();
			
			//活动未开始
			String BeginTime = YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setBeginTime(BeginTime);
			String EndTime = YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setEndTime(EndTime);
			auditproductactivitystockBean.setActivityID(liveActivityId);
			auditproductactivitystockBean.setActivityType(1);
			auditproductactivitystockBean.setProductActivityId(LiveActivityProductId);
			auditproductactivitystockBean.setUserID(sellerId);
			auditproductactivitystockBean.setProductID(productId);
			auditproductactivitystockBean.setStoreType(-1);
			auditproductactivitystockBean.setSourceId(createlive.getId());
			
			ProductActivityStockDto productActivityStockDto1 = new ProductActivityStockDto();
			productActivityStockDto1.setActivityPrice(new BigDecimal(2));
			productActivityStockDto1.setCatalogId(cids.get(0));
			productActivityStockDto1.setSku(null);
			productActivityStockDto1.setStock(300);
			productActivityStockDto1.setAction(0);

			ProductActivityStockDto productActivityStockDto2 = new ProductActivityStockDto();
			productActivityStockDto2.setActivityPrice(new BigDecimal(2));
			productActivityStockDto2.setCatalogId(cids.get(1));
			productActivityStockDto2.setSku(null);
			productActivityStockDto2.setStock(200);
			productActivityStockDto2.setAction(0);
			ProductActivityStockDtoList.add(productActivityStockDto1);
			ProductActivityStockDtoList.add(productActivityStockDto2);
			auditproductactivitystockBean.setFBXCatalogLockList(ProductActivityStockDtoList);
			auditproductactivitystockCall.setData(auditproductactivitystockBean);
			auditproductactivitystockCall.callService();
			String Code = auditproductactivitystockCall.getString("Code");
			Logger.verifyEquals("200",Code,"验证Code");
			LockResult lockResult1 = auditproductactivitystockCall.getBatchLockResults().get(0);
			Logger.verifyEquals(cids.get(0), lockResult1.getCatalogId(), "验证规格编号");
			Logger.verifyEquals(productId, lockResult1.getProductId(), "验证商品编号");
			Logger.verifyEquals(LiveActivityProductId, lockResult1.getProductInActivityId(), "验证商品在活动中Id");
			
			LockResult lockResult2 = auditproductactivitystockCall.getBatchLockResults().get(1);
			Logger.verifyEquals(cids.get(1), lockResult2.getCatalogId(), "验证规格编号");
			Logger.verifyEquals(productId, lockResult2.getProductId(), "验证商品编号");
			Logger.verifyEquals(LiveActivityProductId, lockResult2.getProductInActivityId(), "验证商品在活动中Id");
			
			//发送同步指令SyncActivityProduct
			MessageListBean MessageListBean = MqQueryCallService.initPMongoCrud(productId);
			List <Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if(joa.size()==0){
				Thread.sleep(5000);
				 joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele->{
				Logger.debug(ele.toString());
			});
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_AuditProductActivityStock_014() {
		Logger.start(true,"活动商品，预售活动,action为1");
		try {
			//创建商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			//获取商品ID
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			//获取规格ID
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			//创建一个活动  得到活动id
            Integer activityId = ProductManagerCallServiceV2.createIsolationActivityInProcess();
			//报名活动  获得商品在活动中的id
			List<String> aids = ProductManagerCallServiceV2.ApplyActivity(productId, sellerId,catalogs,activityId, 100,"10");
			//活动未开始
			String BeginTime = YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setBeginTime(BeginTime);
			String EndTime = YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setEndTime(EndTime);
			auditproductactivitystockBean.setActivityID(activityId);
			auditproductactivitystockBean.setActivityType(2);
			auditproductactivitystockBean.setProductActivityId(Integer.valueOf(aids.get(0)));
			auditproductactivitystockBean.setUserID(sellerId);
			auditproductactivitystockBean.setProductID(productId);

			ProductActivityStockDto productActivityStockDto = new ProductActivityStockDto();
			productActivityStockDto.setActivityPrice(new BigDecimal(100));
			productActivityStockDto.setCatalogId(catalogs.get(0));
			productActivityStockDto.setSku(null);
			productActivityStockDto.setStock(200);
			productActivityStockDto.setEarnest(10);
			productActivityStockDto.setEarnestDedution(15);
			productActivityStockDto.setAction(1);
			ProductActivityStockDtoList.add(productActivityStockDto);
			auditproductactivitystockBean.setFBXCatalogLockList(ProductActivityStockDtoList);
			auditproductactivitystockCall.setData(auditproductactivitystockBean);
			auditproductactivitystockCall.callService();
			String Code = auditproductactivitystockCall.getString("Code");
			Logger.verifyEquals("200",Code,"验证Code");
			auditproductactivitystockCall.getBatchLockResults().forEach(pp->{
				Logger.verifyEquals(catalogs.get(0), pp.getCatalogId(), "验证规格编号");
				Logger.verifyEquals(productId, pp.getProductId(), "验证商品编号");
				Logger.verifyEquals(aids.get(0), pp.getProductInActivityId().toString(), "验证商品在活动中Id");
			});
			/**
			 * catalogNum 初始化规格库存
			 * istocknum 初始化活动库存
			 * icatalogNum 初始化后规格库存
			 * inum 初始化后活动库存
			 */
			YmtProductActivityStock activityStock = new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0));
			//定金
			int activityType = activityStock.getActivityType();
			Logger.verifyEquals(productActivityStockDto.getEarnest(),activityStock.getEarnest(),"验证商品定金");
			Logger.verifyEquals(productActivityStockDto.getEarnestDedution(),activityStock.getEarnestDedution(),"验证商品定金立减金额");
			Logger.verifyEquals(productActivityStockDto.getAction(),activityStock.getiAction(),"验证action");
			Logger.verifyEquals(Double.parseDouble(productActivityStockDto.getActivityPrice()+".0"),activityStock.getfActivityPrice(),"验证活动价");
			Logger.verifyEquals(productActivityStockDto.getStock(),activityStock.getIstocknum(),"验证活动库存");
			Logger.verifyEquals(auditproductactivitystockBean.getActivityType(),activityType,"验证activityType");
			Logger.verifyEquals(auditproductactivitystockBean.getUserID(),activityStock.getSellerId(),"验证sellerId");
			Logger.verifyEquals(auditproductactivitystockBean.getProductID(),activityStock.getSproductid(),"验证productId");
			Logger.verifyEquals(auditproductactivitystockBean.getActivityID(),activityStock.getIactivityid(),"验证activityId");

			//活动库存
			Integer istocknum = activityStock.getIstocknum();
			//商品规格库存
			Integer icatalogNum = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).get(0).getiNum();
			Logger.verifyEquals(catalogNum-istocknum,icatalogNum,"验证商品规格库存与预期期望一致");

			//商品活动库存
			Integer inum = new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0)).getIstocknum();
			Logger.verifyEquals(istocknum, inum, "验证商品活动库存与预期期望一致");

			//保证金未缴纳，活动商品暂时不同步到mongo库中的活动商品表
			//发送同步指令SyncActivityProduct
			MessageListBean MessageListBean = MqQueryCallService.initPMongoCrud(productId);
			List <Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if(joa.size()==0){
				Thread.sleep(5000);
				joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele->{
				Logger.debug(ele.toString());
			});

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_AuditProductActivityStock_015() {
		Logger.start(true,"活动商品，预售活动,活动action为0");
		try {
			//创建商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			//获取商品ID
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			//获取规格ID
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			//创建一个活动  得到活动id
			Integer activityId = ProductManagerCallServiceV2.createIsolationActivityInProcess();
			//报名活动  获得商品在活动中的id
			List<String> aids = ProductManagerCallServiceV2.ApplyActivity(productId, sellerId,catalogs,activityId, 100,"10");
			//活动未开始
			String BeginTime = YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setBeginTime(BeginTime);
			String EndTime = YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setEndTime(EndTime);
			auditproductactivitystockBean.setActivityID(activityId);
			auditproductactivitystockBean.setActivityType(2);
			auditproductactivitystockBean.setProductActivityId(Integer.valueOf(aids.get(0)));
			auditproductactivitystockBean.setUserID(sellerId);
			auditproductactivitystockBean.setProductID(productId);

			ProductActivityStockDto productActivityStockDto = new ProductActivityStockDto();
			productActivityStockDto.setActivityPrice(new BigDecimal(100));
			productActivityStockDto.setCatalogId(catalogs.get(0));
			productActivityStockDto.setSku(null);
			int aStock = 200;
			productActivityStockDto.setStock(aStock);
			productActivityStockDto.setEarnest(10);
			productActivityStockDto.setEarnestDedution(15);
			productActivityStockDto.setAction(0);
			ProductActivityStockDtoList.add(productActivityStockDto);
			auditproductactivitystockBean.setFBXCatalogLockList(ProductActivityStockDtoList);
			auditproductactivitystockCall.setData(auditproductactivitystockBean);
			auditproductactivitystockCall.callService();
			String Code = auditproductactivitystockCall.getString("Code");
			Logger.verifyEquals("200",Code,"验证Code");

			YmtCatalogsIWapper ymtCatalogsIWapper = new YmtCatalogsIWapper();
			YmtProductActivityStockWapper ymtProductActivityStockWapper = new YmtProductActivityStockWapper();
			int catalogStock = ymtCatalogsIWapper.selectCatalogsByCatalogId(catalogs.get(0)).getiNum();
			Logger.verifyEquals(catalogStock,catalogNum-aStock,"验证商品规格库存");
			List<YmtProductActivityStock> ymtProductActivityStocks = ymtProductActivityStockWapper.selectByProductId(productId);
			ymtProductActivityStocks.forEach(p->{
				if (p.getScatalogid().equals(catalogs.get(0))){
					Logger.verifyEquals(aStock,p.getIstocknum(),"验证活动库存");
				}
			});
			YmtProductActivityStock activityStock = new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0));
			//定金
			int activityType = activityStock.getActivityType();
			Logger.verifyEquals(productActivityStockDto.getEarnest(),activityStock.getEarnest(),"验证商品定金");
			Logger.verifyEquals(productActivityStockDto.getEarnestDedution(),activityStock.getEarnestDedution(),"验证商品定金立减金额");
			Logger.verifyEquals(productActivityStockDto.getAction(),activityStock.getiAction(),"验证action");
			Logger.verifyEquals(Double.parseDouble(productActivityStockDto.getActivityPrice()+".0"),activityStock.getfActivityPrice(),"验证活动价");
			Logger.verifyEquals(productActivityStockDto.getStock(),activityStock.getIstocknum(),"验证活动库存");
			Logger.verifyEquals(auditproductactivitystockBean.getActivityType(),activityType,"验证activityType");
			Logger.verifyEquals(auditproductactivitystockBean.getUserID(),activityStock.getSellerId(),"验证sellerId");
			Logger.verifyEquals(auditproductactivitystockBean.getProductID(),activityStock.getSproductid(),"验证productId");
			Logger.verifyEquals(auditproductactivitystockBean.getActivityID(),activityStock.getIactivityid(),"验证activityId");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

    @Test
    @Category({P1.class})
    @TestCase
    public void Tc_AuditProductActivityStock_016() {
        Logger.start(true,"活动商品，预售活动,定金和定金立减为空");
        try {
            //创建商品
            AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
            // 设置商品库存,规格库存
            Integer catalogNum = 1000;
            addpro.getProduct().getCatalogList().forEach(catalog -> {
                catalog.setStock(catalogNum);
            });
            //获取商品ID
            String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
            //获取规格ID
            List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
            //创建一个活动  得到活动id
            Integer activityId = ProductManagerCallServiceV2.createIsolationActivityInProcess();
            //报名活动  获得商品在活动中的id
            List<String> aids = ProductManagerCallServiceV2.ApplyActivity(productId, sellerId,catalogs,activityId, 100,"10");
            //活动未开始
            String BeginTime = YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING);
            auditproductactivitystockBean.setBeginTime(BeginTime);
            String EndTime = YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING);
            auditproductactivitystockBean.setEndTime(EndTime);
            auditproductactivitystockBean.setActivityID(activityId);
            auditproductactivitystockBean.setActivityType(2);
            auditproductactivitystockBean.setProductActivityId(Integer.valueOf(aids.get(0)));
            auditproductactivitystockBean.setUserID(sellerId);
            auditproductactivitystockBean.setProductID(productId);

            ProductActivityStockDto productActivityStockDto = new ProductActivityStockDto();
            productActivityStockDto.setActivityPrice(new BigDecimal(100));
            productActivityStockDto.setCatalogId(catalogs.get(0));
            productActivityStockDto.setSku(null);
            productActivityStockDto.setStock(200);
            productActivityStockDto.setAction(1);
            ProductActivityStockDtoList.add(productActivityStockDto);
            auditproductactivitystockBean.setFBXCatalogLockList(ProductActivityStockDtoList);
            auditproductactivitystockCall.setData(auditproductactivitystockBean);
            auditproductactivitystockCall.callService();
            String Code = auditproductactivitystockCall.getString("Code");
            Logger.verifyEquals("201",Code,"验证Code");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P1.class})
    @TestCase
    public void Tc_AuditProductActivityStock_017() {
        Logger.start(true,"活动商品，预售活动,第一次报名活动未审核，不同步mongo，第二次报名未审核也不会同步mongo，扣活动库存");
        try {
            //创建商品
            AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
            // 设置商品库存,规格库存
            Integer catalogNum = 1000;
            addpro.getProduct().getCatalogList().forEach(catalog -> {
                catalog.setStock(catalogNum);
            });
            //获取商品ID
            String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
            //获取规格ID
            List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
            //创建一个活动  得到活动id
            Integer activityId = ProductManagerCallServiceV2.createIsolationActivityInProcess();
            //报名活动  获得商品在活动中的id
            List<String> aids = ProductManagerCallServiceV2.ApplyActivity(productId, sellerId,catalogs,activityId, 100,"10");
            //活动未开始
            String BeginTime = YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING);
            auditproductactivitystockBean.setBeginTime(BeginTime);
            String EndTime = YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING);
            auditproductactivitystockBean.setEndTime(EndTime);
            auditproductactivitystockBean.setActivityID(activityId);
            auditproductactivitystockBean.setActivityType(2);
            auditproductactivitystockBean.setProductActivityId(Integer.valueOf(aids.get(0)));
            auditproductactivitystockBean.setUserID(sellerId);
            auditproductactivitystockBean.setProductID(productId);

            ProductActivityStockDto productActivityStockDto = new ProductActivityStockDto();
            productActivityStockDto.setActivityPrice(new BigDecimal(100));
            productActivityStockDto.setCatalogId(catalogs.get(0));
            productActivityStockDto.setSku(null);
            productActivityStockDto.setStock(200);
            productActivityStockDto.setEarnest(10);
            productActivityStockDto.setEarnestDedution(15);
            productActivityStockDto.setAction(1);
            ProductActivityStockDtoList.add(productActivityStockDto);
            auditproductactivitystockBean.setFBXCatalogLockList(ProductActivityStockDtoList);
            auditproductactivitystockCall.setData(auditproductactivitystockBean);
            auditproductactivitystockCall.callService();
            String Code = auditproductactivitystockCall.getString("Code");
            Logger.verifyEquals("200",Code,"验证Code");
            auditproductactivitystockCall.getBatchLockResults().forEach(pp->{
                Logger.verifyEquals(catalogs.get(0), pp.getCatalogId(), "验证规格编号");
                Logger.verifyEquals(productId, pp.getProductId(), "验证商品编号");
                Logger.verifyEquals(aids.get(0), pp.getProductInActivityId().toString(), "验证商品在活动中Id");
            });
            /**
             * catalogNum 初始化规格库存
             * istocknum 初始化活动库存
             * icatalogNum 初始化后规格库存
             * inum 初始化后活动库存
             */
            YmtProductActivityStock activityStock = new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0));
            //定金
            int activityType = activityStock.getActivityType();
            Logger.verifyEquals(productActivityStockDto.getEarnest(),activityStock.getEarnest(),"验证商品定金");
            Logger.verifyEquals(productActivityStockDto.getEarnestDedution(),activityStock.getEarnestDedution(),"验证商品定金立减金额");
            Logger.verifyEquals(productActivityStockDto.getAction(),activityStock.getiAction(),"验证action");
            Logger.verifyEquals(Double.parseDouble(productActivityStockDto.getActivityPrice()+".0"),activityStock.getfActivityPrice(),"验证活动价");
            Logger.verifyEquals(productActivityStockDto.getStock(),activityStock.getIstocknum(),"验证活动库存");
            Logger.verifyEquals(auditproductactivitystockBean.getActivityType(),activityType,"验证activityType");
            Logger.verifyEquals(auditproductactivitystockBean.getUserID(),activityStock.getSellerId(),"验证sellerId");
            Logger.verifyEquals(auditproductactivitystockBean.getProductID(),activityStock.getSproductid(),"验证productId");
            Logger.verifyEquals(auditproductactivitystockBean.getActivityID(),activityStock.getIactivityid(),"验证activityId");

            //活动库存
            Integer istocknum = activityStock.getIstocknum();
            //商品规格库存
            Integer icatalogNum = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).get(0).getiNum();
            Logger.verifyEquals(catalogNum-istocknum,icatalogNum,"验证商品规格库存与预期期望一致");

            //商品活动库存
            Integer inum = new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0)).getIstocknum();
            Logger.verifyEquals(istocknum, inum, "验证商品活动库存与预期期望一致");

            //保证金未缴纳，活动商品暂时不同步到mongo库中的活动商品表
            //发送同步指令SyncActivityProduct
            MessageListBean MessageListBean = MqQueryCallService.initPMongoCrud(productId);
            List <Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
            if(joa.size()==0){
                Thread.sleep(5000);
                joa = MqQueryCallService.GetMqMessage(MessageListBean);
            }
            joa.forEach(ele->{
                Logger.debug(ele.toString());
            });

            //第二次报名，mongo库中应该未同步，没有数据
            auditproductactivitystockCall.callService();
            List<Map> activityProducts = new ProductsWapperV2().getActivityProductByProductId(productId);
            Logger.verifyEquals(new ArrayList<>(),activityProducts,"验证活动商品没有同步到mongo库中的ActivityProducts中");
            Logger.verifyEquals(catalogNum-istocknum,icatalogNum,"验证商品规格库存与预期期望一致");
            Logger.verifyEquals(istocknum, inum, "验证商品活动库存与预期期望一致");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    
    
    @Test
	@Category({P1.class})
	@TestCase
	public void Tc_AuditProductActivityStock_018() {
		Logger.start(true,"活动商品，活动规格，1000库存，报名200个，报名十次，防止并发");
		try {
			//创建商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			
			//获取商品ID
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			//获取规格ID
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			//创建一个活动  得到活动id
			Integer activityId = ProductManagerCallServiceV2.createIsolationActivityInProcess();
			//报名活动  获得商品在活动中的id
			List<String> aids = ProductManagerCallServiceV2.ApplyActivity(productId, sellerId,catalogs,activityId, 100,"10");
			//活动未开始
			String BeginTime = YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setBeginTime(BeginTime);
			String EndTime = YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setEndTime(EndTime);
			auditproductactivitystockBean.setActivityID(activityId);
			auditproductactivitystockBean.setActivityType(0);
			auditproductactivitystockBean.setProductActivityId(Integer.valueOf(aids.get(0)));
			auditproductactivitystockBean.setUserID(sellerId);
			auditproductactivitystockBean.setProductID(productId);
			auditproductactivitystockBean.setStoreType(-1);
			
			ProductActivityStockDto productActivityStockDto = new ProductActivityStockDto();
			productActivityStockDto.setActivityPrice(new BigDecimal(10));
			productActivityStockDto.setCatalogId(catalogs.get(0));
			productActivityStockDto.setSku(null);
			productActivityStockDto.setStock(200);
			ProductActivityStockDtoList.add(productActivityStockDto);
			auditproductactivitystockBean.setFBXCatalogLockList(ProductActivityStockDtoList);
			auditproductactivitystockCall.setData(auditproductactivitystockBean);
			for (int i = 0; i <5; i++) {
				auditproductactivitystockCall.callService();
			}
			//Logger.debug("活动库存1:"+FormatUtil.beanToGSONString(new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0))));
			String Code = auditproductactivitystockCall.getString("Code");
			Logger.verifyEquals("200",Code,"验证Code");
			auditproductactivitystockCall.getBatchLockResults().forEach(pp->{
				Logger.verifyEquals(catalogs.get(0), pp.getCatalogId(), "验证规格编号");
				Logger.verifyEquals(productId, pp.getProductId(), "验证商品编号");
				Logger.verifyEquals(aids.get(0), pp.getProductInActivityId().toString(), "验证商品在活动中Id");
			});
			/**
			 * catalogNum 初始化规格库存
			 * istocknum 初始化活动库存
			 * icatalogNum 初始化后规格库存
			 * inum 初始化后活动库存
			 */
			//活动库存
			Integer istocknum = new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0)).getIstocknum();
			//商品规格库存
			Integer icatalogNum = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).get(0).getiNum();
			System.out.println("原本规格库存："+catalogNum+"\r\n调用十次后--活动库存："+istocknum+"规格库存："+icatalogNum);
			Logger.verifyEquals(catalogNum-istocknum,icatalogNum,"验证商品规格库存与预期期望一致");
			
			//商品活动库存
			Integer inum = new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0)).getIstocknum();
			Logger.verifyEquals(istocknum, inum, "验证商品活动库存与预期期望一致");
			
			//发送同步指令SyncActivityProduct
			MessageListBean MessageListBean = MqQueryCallService.initPMongoCrud(productId);
			List <Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if(joa.size()==0){
				Thread.sleep(5000);
				 joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele->{
				Logger.debug(ele.toString());
			});
			

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
    @Test
	@Category({P1.class})
	@TestCase
	public void Tc_AuditProductActivityStock_019() {
		Logger.start(true,"活动商品，活动规格，第一次参加活动-新增Job记录ProductStock.ActivityProductStartOrEnd");
		try {
			//创建商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			
			//获取商品ID
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			//获取规格ID
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			//创建一个活动  得到活动id
			Integer activityId = ProductManagerCallServiceV2.createIsolationActivityInProcess();
			//报名活动  获得商品在活动中的id
			List<String> aids = ProductManagerCallServiceV2.ApplyActivity(productId, sellerId,catalogs,activityId, 100,"10");
			
			
			//活动未开始
			String BeginTime = YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setBeginTime(BeginTime);
			String EndTime = YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setEndTime(EndTime);
			auditproductactivitystockBean.setActivityID(activityId);
			auditproductactivitystockBean.setActivityType(0);
			auditproductactivitystockBean.setProductActivityId(Integer.valueOf(aids.get(0)));
			auditproductactivitystockBean.setUserID(sellerId);
			auditproductactivitystockBean.setProductID(productId);
			auditproductactivitystockBean.setStoreType(-1);
			
			ProductActivityStockDto productActivityStockDto = new ProductActivityStockDto();
			productActivityStockDto.setActivityPrice(new BigDecimal(10));
			productActivityStockDto.setCatalogId(catalogs.get(0));
			productActivityStockDto.setSku(null);
			productActivityStockDto.setStock(200);
			ProductActivityStockDtoList.add(productActivityStockDto);
			auditproductactivitystockBean.setFBXCatalogLockList(ProductActivityStockDtoList);
			auditproductactivitystockCall.setData(auditproductactivitystockBean);
			auditproductactivitystockCall.callService();
			//Logger.debug("活动库存1:"+FormatUtil.beanToGSONString(new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0))));
			String Code = auditproductactivitystockCall.getString("Code");
			Logger.verifyEquals("200",Code,"验证Code");
			auditproductactivitystockCall.getBatchLockResults().forEach(pp->{
				Logger.verifyEquals(catalogs.get(0), pp.getCatalogId(), "验证规格编号");
				Logger.verifyEquals(productId, pp.getProductId(), "验证商品编号");
				Logger.verifyEquals(aids.get(0), pp.getProductInActivityId().toString(), "验证商品在活动中Id");
			});
			/**
			 * catalogNum 初始化规格库存
			 * istocknum 初始化活动库存
			 * icatalogNum 初始化后规格库存
			 * inum 初始化后活动库存
			 */
			//活动库存
			Integer istocknum = new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0)).getIstocknum();
			//商品规格库存
			Integer icatalogNum = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).get(0).getiNum();
			Logger.verifyEquals(catalogNum-istocknum,icatalogNum,"验证商品规格库存与预期期望一致");
			
			//商品活动库存
			Integer inum = new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0)).getIstocknum();
			Logger.verifyEquals(istocknum, inum, "验证商品活动库存与预期期望一致");
			
			//发送同步指令SyncActivityProduct
			MessageListBean MessageListBean = MqQueryCallService.initPMongoCrud(productId);
			 List<Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if(joa.size()==0){
				Thread.sleep(5000);
				 joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele->{
				Logger.debug(ele.toString());
			});
			//验证start
			JobTaskitemListBean jobListBean = JobQueryCallService.initActivityProductStartOrEnd(productId,activityId,"START");
			joa = JobQueryCallService.GetJobTasks(jobListBean);
			if(joa.size()==0){
				Thread.sleep(5000);
				 joa = JobQueryCallService.GetJobTasks(jobListBean);
			}
			Logger.verifyEquals(1, joa.size(), "验证有start记录");
			joa.forEach(ele->{
				Logger.debug(ele.toString());
			});
			
			//验证end
			jobListBean = JobQueryCallService.initActivityProductStartOrEnd(productId,activityId,"END");
			joa = JobQueryCallService.GetJobTasks(jobListBean);
			if(joa.size()==0){
				Thread.sleep(5000);
				 joa = JobQueryCallService.GetJobTasks(jobListBean);
			}
			joa.forEach(ele->{
				Logger.debug(ele.toString());
			});
			Logger.verifyEquals(1, joa.size(), "验证有end记录");
			String nexttime2=joa.get(0).get("nextTime").toString();
			Logger.debug("nexttime2:"+nexttime2);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
    
    
    
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_AuditProductActivityStock_020() {
		Logger.start(true,"直播秒杀商品，活动规格，第一次参加活动  初始化redis");
		try {
			Logger.comment("创建商品");
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Logger.comment("创建直播");
			// 5分钟后开始200分钟后结束
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			//半小时之内会锁定不能修改
			
			Date starttime = new Date(now.getTime() + 60 * 60 * 1000);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));
			
			LiveRoom createlive = LiveRoomCallService.CreateSellerLive(clive);
			Logger.comment("加入商品");
			LiveRoomCallService.AddProductsToLive(createlive.getId(), sellerId, productId);
			Logger.comment("查询商品规格");
			YmtCatalogsIWapper CIWapper = new YmtCatalogsIWapper();
			List<String> cids = CIWapper.selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			Logger.comment("创建秒杀活动");
			
			CreateLiveActivityBean createliveactivityBean = new CreateLiveActivityBean();
			LiveActivityDto LiveActivity=new LiveActivityDto();
			List<ActivityProductDto> ActivityProducts=new ArrayList<>();
			ActivityProductDto activityProductDto1 = new ActivityProductDto();
			activityProductDto1.setProductId(productId);
			activityProductDto1.setActivityPrice(7d);
			activityProductDto1.setActivityStock(6);
			activityProductDto1.setCatalogId(cids.get(0));
			ActivityProductDto activityProductDto2 = new ActivityProductDto();
			activityProductDto2.setProductId(productId);
			activityProductDto2.setActivityPrice(7d);
			activityProductDto2.setActivityStock(6);
			activityProductDto2.setCatalogId(cids.get(1));
			ActivityProducts.add(activityProductDto1);
			ActivityProducts.add(activityProductDto2);
			
			LiveActivity.setActivityProducts(ActivityProducts);
			LiveActivity.setStartTime(String.valueOf(starttime.getTime()));
			LiveActivity.setEndTime(String.valueOf(starttime.getTime()+1*60*1000));
			LiveActivity.setLiveId(createlive.getId());
			LiveActivity.setSellerId(sellerId);
			createliveactivityBean.setLiveActivity(LiveActivity);
			
			createliveactivityBean.getLiveActivity().setActivityProducts(ActivityProducts);
			LiveRoomCallService.CreateLiveActivity(createliveactivityBean);
			LiveRoomWapper LiveRoomWapper = new LiveRoomWapper();
			Integer liveActivityId = LiveRoomWapper.selectLiveactivityByLiveId(createliveactivityBean.getLiveActivity().getLiveId()).get(0).getLiveActivityId();
			Integer LiveActivityProductId = LiveRoomWapper.selectLiveactivityproduct(liveActivityId, LiveActivity.getActivityProducts().get(0).getProductId()).get(0).getLiveActivityProductId();
			//添加秒杀商品数据
			ProductManagerCallServiceV2.addSecKillStock(liveActivityId, productId, sellerId, true);
			//活动未开始
			
			String BeginTime = YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setBeginTime(BeginTime);
			String EndTime = YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setEndTime(EndTime);
			auditproductactivitystockBean.setActivityID(liveActivityId);
			auditproductactivitystockBean.setActivityType(1);
			auditproductactivitystockBean.setProductActivityId(LiveActivityProductId);
			auditproductactivitystockBean.setUserID(sellerId);
			auditproductactivitystockBean.setProductID(productId);
			auditproductactivitystockBean.setStoreType(-1);
            auditproductactivitystockBean.setSourceId(createlive.getId());
			auditproductactivitystockBean.setSourceId(createlive.getId());
			
			ProductActivityStockDto productActivityStockDto1 = new ProductActivityStockDto();
			productActivityStockDto1.setActivityPrice(new BigDecimal(2));
			productActivityStockDto1.setCatalogId(cids.get(0));
			productActivityStockDto1.setSku(null);
			productActivityStockDto1.setStock(200);
			productActivityStockDto1.setAction(0);

			ProductActivityStockDto productActivityStockDto2 = new ProductActivityStockDto();
			productActivityStockDto2.setActivityPrice(new BigDecimal(2));
			productActivityStockDto2.setCatalogId(cids.get(1));
			productActivityStockDto2.setSku(null);
			productActivityStockDto2.setStock(300);
			productActivityStockDto2.setAction(0);
			ProductActivityStockDtoList.add(productActivityStockDto1);
			ProductActivityStockDtoList.add(productActivityStockDto2);
			auditproductactivitystockBean.setFBXCatalogLockList(ProductActivityStockDtoList);
			auditproductactivitystockCall.setData(auditproductactivitystockBean);
			auditproductactivitystockCall.callService();
			//Logger.debug("活动库存1:"+FormatUtil.beanToGSONString(new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0))));
			String Code = auditproductactivitystockCall.getString("Code");
			Logger.verifyEquals("200",Code,"验证Code");

			Integer pia = auditproductactivitystockCall.getBatchLockResults().get(0).getProductInActivityId();
			String catalogId = auditproductactivitystockCall.getBatchLockResults().get(0).getCatalogId();
			RedisDriver rd = new RedisDriver("group1",EnvSetup.getSystemUrl("sentinel"));
			Logger.verifyEquals(rd.getValue("SecStock:"+pia+":"+catalogId),auditproductactivitystockBean.getFBXCatalogLockList().get(0).getStock()+"", "验证redis库存");
			long ttl=rd.getTtl("SecStock:"+pia+":"+catalogId)*1000;
			Logger.verifyEquals((int)((ttl-endtime.getTime()+starttime.getTime())/1000/60/60/24), 31, "判断ttl自结束日期起向后延长30天");
			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_AuditProductActivityStock_021() {
		Logger.start(true,"活动商品，活动规格，第一次参加活动  初始化redis");
		try {
			//创建商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			// 设置商品库存,规格库存
			Integer catalogNum = 1000;
			addpro.getProduct().getCatalogList().forEach(catalog -> {
				catalog.setStock(catalogNum);
			});
			
			//获取商品ID
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			//获取规格ID
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			//创建一个活动  得到活动id
			Integer activityId = ProductManagerCallServiceV2.createIsolationActivityInProcess();
			//报名活动  获得商品在活动中的id
			List<String> aids = ProductManagerCallServiceV2.ApplyActivity(productId, sellerId,catalogs,activityId, 100,"10");
			//添加秒杀商品数据
			ProductManagerCallServiceV2.addSecKillStock(activityId,productId, sellerId, true);
			//审核通过
			ProductManagerCallServiceV2.approveProductInActivity(productId,aids.get(0),true);
			
			String BeginTime = YMTDateUtil.getBeforeOrNextDay(1, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setBeginTime(BeginTime);
			String EndTime = YMTDateUtil.getBeforeOrNextDay(2, YMTDateUtil.YMDTHMS_STRING);
			auditproductactivitystockBean.setEndTime(EndTime);
			auditproductactivitystockBean.setActivityID(activityId);
			auditproductactivitystockBean.setActivityType(0);
			auditproductactivitystockBean.setProductActivityId(Integer.valueOf(aids.get(0)));
			auditproductactivitystockBean.setUserID(sellerId);
			auditproductactivitystockBean.setProductID(productId);
			
			
			ProductActivityStockDto productActivityStockDto = new ProductActivityStockDto();
			productActivityStockDto.setActivityPrice(new BigDecimal(10));
			productActivityStockDto.setCatalogId(catalogs.get(0));
			productActivityStockDto.setSku(null);
			productActivityStockDto.setStock(200);
			productActivityStockDto.setAction(0);
			ProductActivityStockDtoList.add(productActivityStockDto);

			auditproductactivitystockBean.setFBXCatalogLockList(ProductActivityStockDtoList);
			auditproductactivitystockCall.setData(auditproductactivitystockBean);
			auditproductactivitystockCall.callService();
			//Logger.debug("活动库存1:"+FormatUtil.beanToGSONString(new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0))));
			String Code = auditproductactivitystockCall.getString("Code");
			Logger.verifyEquals("200",Code,"验证Code");
			auditproductactivitystockCall.getBatchLockResults().forEach(pp->{
				Logger.verifyEquals(catalogs.get(0), pp.getCatalogId(), "验证规格编号");
				Logger.verifyEquals(productId, pp.getProductId(), "验证商品编号");
				Logger.verifyEquals(aids.get(0), pp.getProductInActivityId().toString(), "验证商品在活动中Id");
			});
			/**
			 * catalogNum 初始化规格库存
			 * istocknum 初始化活动库存
			 * icatalogNum 初始化后规格库存
			 * inum 初始化后活动库存
			 */
			//活动库存
			Integer istocknum = new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0)).getIstocknum();
			//商品规格库存
			Integer icatalogNum = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).get(0).getiNum();
			Logger.verifyEquals(catalogNum-istocknum,icatalogNum,"验证商品规格库存与预期期望一致");
			//商品活动库存
			Integer inum = new YmtProductActivityStockWapper().selectByCatalogId(catalogs.get(0)).getIstocknum();
			Logger.verifyEquals(istocknum, inum, "验证商品活动库存与预期期望一致");
			
			//发送同步指令SyncActivityProduct
			MessageListBean MessageListBean = MqQueryCallService.initPMongoCrud(productId);
			List <Map> joa = MqQueryCallService.GetMqMessage(MessageListBean);
			if(joa.size()==0){
				Thread.sleep(5000);
				 joa = MqQueryCallService.GetMqMessage(MessageListBean);
			}
			joa.forEach(ele->{
				Logger.debug(ele.toString());
			});
			
			RedisDriver rd = new RedisDriver("group1",EnvSetup.getSystemUrl("sentinel"));
			String key="SecStock:"+aids.get(0)+":"+catalogs.get(0);
			Logger.comment("获取redis，key为："+key+"值为："+rd.getValue(key));
			Logger.verifyEquals(rd.getValue(key),""+auditproductactivitystockBean.getFBXCatalogLockList().get(0).getStock(), "验证redis库存");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	

}